package kr.hikt.androidcomplete01.ch05;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class RelativeWork extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		RelativeLayout rel = new RelativeLayout(this);
		
		TextView tv1 = new TextView(this);
		tv1.setId(1);
		tv1.setText("철수");
		tv1.setTextSize(30);
		RelativeLayout.LayoutParams pt1 = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		pt1.setMargins(0, 0, 20, 0);
		rel.addView(tv1, pt1);
		
		TextView tv2 = new TextView(this);
		tv2.setId(2);
		tv2.setText("영희");
		tv2.setTextSize(20);
		RelativeLayout.LayoutParams pt2 = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		pt2.addRule(RelativeLayout.RIGHT_OF, tv1.getId());
		rel.addView(tv2, pt2);
		
		TextView tv3 = new TextView(this);
		tv3.setId(3);
		tv3.setText("몽룡");
		tv3.setTextSize(30);
		RelativeLayout.LayoutParams pt3 = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		pt3.setMargins(30, 0, 0, 0);
		pt3.addRule(RelativeLayout.BELOW, tv2.getId());
		pt3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		rel.addView(tv3, pt3);
		
		TextView tv4 = new TextView(this);
		tv4.setId(4);
		tv4.setText("춘향");
		tv4.setTextSize(20);
		RelativeLayout.LayoutParams pt4 = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.WRAP_CONTENT,
				RelativeLayout.LayoutParams.WRAP_CONTENT);
		pt4.setMargins(10, 0, 0, 0);
		pt4.addRule(RelativeLayout.LEFT_OF, tv3.getId());
		pt4.addRule(RelativeLayout.ALIGN_BOTTOM, tv3.getId());
		rel.addView(tv4, pt4);
		
		setContentView(rel);
	}
}
